package com.cs.game.core.view.imageview;

import com.cs.game.core.constant.Constants;
import javafx.scene.image.Image;

public class Turtle extends Actor {
    Image turtle1;
    Image turtle2;
    Image turtle3;
    private int speed;
    int i = 1;
    boolean bool = true;

    @Override
    public void act(long now) {

        if (now / 900000000 % 3 == 0) {
            setImage(turtle2);

        } else if (now / 900000000 % 3 == 1) {
            setImage(turtle1);

        } else if (now / 900000000 % 3 == 2) {
            setImage(turtle3);

        }

        move(speed, 0);
        if (getX() > 600 && speed > 0) {
            setX(-200);
        }
        if (getX() < -75 && speed < 0) {
            setX(600);
        }
    }

    public Turtle(int xpos, int ypos, int s, int w, int h) {
        String imgTurtleAnimation1 = this.getClass().getClassLoader().getResource(Constants.IMAGE_TURTLEANIMATION1_PATH).toString();
        String imgTurtleAnimation2 = this.getClass().getClassLoader().getResource(Constants.IMAGE_TURTLEANIMATION2_PATH).toString();
        String imgTurtleAnimation3 = this.getClass().getClassLoader().getResource(Constants.IMAGE_TURTLEANIMATION3_PATH).toString();
        turtle1 = new Image(imgTurtleAnimation1, w, h, true, true);
        turtle2 = new Image(imgTurtleAnimation2, w, h, true, true);
        turtle3 = new Image(imgTurtleAnimation3, w, h, true, true);
        setX(xpos);
        setY(ypos);
        speed = s;
        setImage(turtle2);
    }
}
